//
//  regex.m
//  gdemm
//
//  Created by 李园园 on 16/11/14.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "regex.h"

@implementation regex
//用户名 1-20字节,由数字,字母,下划线,点组成
+(BOOL)isCorrectName:(NSString *)name{
    NSString *regex = @"^[A-Za-z0-9_.]{1,20}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    if([pred evaluateWithObject: name])
    {
        return YES;
    }else{
        return NO;
    }

}
//密码是8-16个字节,由数字,字母,下划线,点组成
+(BOOL)isCorrectPwd:(NSString *)pwd{
    NSString *regex = @"^[A-Za-z0-9_.]{8,16}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    if([pred evaluateWithObject: pwd])
    {
        return YES;
    }else{
        return NO;
    }
}
@end
